package main

open class Parent
class Child : Parent()

fun main() {
    val parent: Parent = Child()
    if (parent is Child) {
        println(parent.javaClass.simpleName)
    }
    val parent1: Parent = Parent()
    //加上as强制转换，加上？则在转换失败的时候不会抛出异常而是返回null
    val child: Child? = parent1 as? Child
    println(child ?: "转换失败")
}